import { applyMiddleware, createStore } from "redux"
import thunk from "redux-thunk"
import { LOG_OUT, SET_USER } from "./action_type";

const initialData = {
    user: {}
}

const reducer = (state = initialData,action) => {
    switch(action.type) {
        case SET_USER:
            const user = action.user;
            return {
                ...state,
                user
            }
        case LOG_OUT: 
            return  {
                user: {}
            }
        default:
            return state;
    }
}

export default createStore(reducer,applyMiddleware(thunk));